package cn.chiship.framework.upms.biz.user.service;

import cn.chiship.framework.common.enums.LoginTypeEnum;
import cn.chiship.framework.upms.biz.user.entity.UpmsUserOrganization;
import cn.chiship.framework.upms.biz.user.pojo.vo.UpmsUserVo;
import cn.chiship.sdk.cache.vo.CacheUserVO;
import cn.chiship.sdk.framework.base.BaseService;
import cn.chiship.sdk.core.base.BaseResult;
import cn.chiship.framework.upms.biz.user.entity.UpmsUser;
import cn.chiship.framework.upms.biz.user.entity.UpmsUserExample;
import cn.chiship.sdk.framework.pojo.vo.PageVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import java.util.HashMap;
import java.util.List;

/**
 * 用户业务接口层
 * 2021/9/27
 *
 * @author lijian
 */
public interface UpmsUserService extends BaseService<UpmsUser, UpmsUserExample> {

    /**
     * 分页
     *
     * @param pageVo
     * @return
     */
    BaseResult page(PageVo pageVo);

    /**
     * 保存用户
     *
     * @param upmsUser
     * @param userOrganization
     * @param role
     * @return
     */
    BaseResult saveUser(UpmsUser upmsUser, UpmsUserOrganization userOrganization, String role);

    /**
     * 更新用户
     *
     * @param upmsUser
     * @param userOrganization
     * @param role
     * @return
     */
    BaseResult updateUser(UpmsUser upmsUser, UpmsUserOrganization userOrganization, String role);

    /**
     * 删除用户
     *
     * @param userIds
     * @return
     */
    BaseResult removeUser(List<String> userIds);

    /**
     * 根据用户主键获取用户详情
     *
     * @param id
     * @return
     */
    BaseResult getUserById(String id);

    /**
     * 根据手机号获取用户
     *
     * @param mobile
     * @return
     */
    BaseResult getUserByMobile(String mobile);


    /**
     * 登录
     *
     * @param sessionId
     * @param username
     * @param password
     * @param loginIp
     * @param loginTypeEnum
     * @return
     */
    BaseResult login(String sessionId, String username, String password, String loginIp, LoginTypeEnum loginTypeEnum);

    /**
     * 手机号登录
     *
     * @param sessionId
     * @param mobile
     * @param loginIp
     * @param loginTypeEnum
     * @return
     */
    BaseResult mobileLogin(String sessionId, String mobile, String loginIp, LoginTypeEnum loginTypeEnum);

    /**
     * 扫码登录
     *
     * @param sessionId
     * @param username
     * @param loginIp
     * @param loginTypeEnum
     * @return
     */
    BaseResult scanLogin(String sessionId, String username, String loginIp, LoginTypeEnum loginTypeEnum);

    /**
     * 注册
     *
     * @param mobile
     * @param realName
     * @param password
     * @param passwordAgain
     * @return
     */
    BaseResult register(String mobile, String realName, String password, String passwordAgain);

    /**
     * 加入组织
     *
     * @param cacheUserVO
     * @param invitationCode
     * @param realName
     * @return
     */
    BaseResult joinOrg(CacheUserVO cacheUserVO, String invitationCode, String realName);

    /**
     * 退出组织
     *
     * @param cacheUserVO
     * @param organizationId
     * @return
     */
    BaseResult leaveOrg(CacheUserVO cacheUserVO, String organizationId);

    /**
     * 进入企业
     *
     * @param cacheUserVO
     * @param organizationId
     * @return
     */
    BaseResult enterOrg(CacheUserVO cacheUserVO, String organizationId);

    /**
     * 切换部门
     * @param cacheUserVO
     * @param deptId
     * @return
     */
    BaseResult changeDept(CacheUserVO cacheUserVO,String deptId);


    /**
     * 校验用户是否加入组织
     *
     * @param userId
     * @param invitationCode
     * @return
     */
    BaseResult checkJoinOrg(String userId, String invitationCode);

    /**
     * 修改密码
     *
     * @param userId
     * @param oldPassword
     * @param newPassword
     * @param newPasswordAgain
     * @return
     */
    BaseResult modifyPassword(String userId, String oldPassword, String newPassword, String newPasswordAgain);

    /**
     * 忘记密码
     *
     * @param mobile
     * @param password
     * @param passwordAgain
     * @return
     */
    BaseResult forgotPassword(String mobile, String password, String passwordAgain);

    /**
     * 修改头像
     *
     * @param avatar
     * @param cacheUserVO
     * @return
     */
    BaseResult modifyAvatar(String avatar, CacheUserVO cacheUserVO);

    /**
     * 设置用户名
     *
     * @param userName
     * @param id
     * @return
     */
    BaseResult modifyUserName(String userName, String id);

    /**
     * 修改手机号
     *
     * @param newMobile
     * @param cacheUserVO
     * @return
     */
    BaseResult modifyMobile(String newMobile, CacheUserVO cacheUserVO);

    /**
     * 修改邮箱
     *
     * @param newEmail
     * @param cacheUserVO
     * @return
     */
    BaseResult modifyEmail(String newEmail, CacheUserVO cacheUserVO);

    /**
     * 解锁
     *
     * @param userId
     * @param password
     * @param ip
     * @return
     */
    BaseResult unlock(String userId, String password, String ip);

    /**
     * 初始化密码
     *
     * @param ids
     * @return
     */
    BaseResult initialPassword(List<String> ids);

    /**
     * 锁定与启动
     *
     * @param id
     * @param isLocked
     * @return
     */
    BaseResult changeIsLocked(String id, Boolean isLocked);

    /**
     * 用户组织调整
     *
     * @param id
     * @param targetOrg
     * @return
     */
    BaseResult adjustmentOrg(String id, String targetOrg);


}
